package com.ruoyi.merchant.service.impl;

import java.util.List;
import java.util.Map;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.crypto.SecureUtil;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.db.mapper.MerchantApplyInfoMapper;
import com.ruoyi.db.domain.MerchantApplyInfo;
import com.ruoyi.merchant.service.IMerchantApplyInfoService;

/**
 * 商户申请信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-06-24
 */
@Service
@DataSource(DataSourceType.SLAVE)
public class MerchantApplyInfoServiceImpl implements IMerchantApplyInfoService 
{
    @Autowired
    private MerchantApplyInfoMapper merchantApplyInfoMapper;

    /**
     * 查询商户申请信息
     * 
     * @param id 商户申请信息主键
     * @return 商户申请信息
     */
    @Override
    public MerchantApplyInfo selectMerchantApplyInfoById(Long id)
    {
        return merchantApplyInfoMapper.selectMerchantApplyInfoById(id);
    }

    /**
     * 查询商户申请信息列表
     * 
     * @param merchantApplyInfo 商户申请信息
     * @return 商户申请信息
     */
    @Override
    public List<MerchantApplyInfo> selectMerchantApplyInfoList(MerchantApplyInfo merchantApplyInfo)
    {
        return merchantApplyInfoMapper.selectMerchantApplyInfoList(merchantApplyInfo);
    }

    /**
     * 查询商户申请信息列表
     *
     * @param merchantApplyInfo 商户申请信息
     * @return 商户申请信息
     */
    @Override
    public List<Map<String, Object>> selectMerchantApplyInfoMapList(MerchantApplyInfo merchantApplyInfo)
    {
        return merchantApplyInfoMapper.selectMerchantApplyInfoMapList(merchantApplyInfo);
    }

    /**
     * 新增商户申请信息
     * 
     * @param merchantApplyInfo 商户申请信息
     * @return 结果
     */
    @Override
    public int insertMerchantApplyInfo(MerchantApplyInfo merchantApplyInfo)
    {
        merchantApplyInfo.setCreateTime(DateUtils.getNowDate());
        return merchantApplyInfoMapper.insertMerchantApplyInfo(merchantApplyInfo);
    }

    /**
     * 修改商户申请信息
     * 
     * @param merchantApplyInfo 商户申请信息
     * @return 结果
     */
    @Override
    public int updateMerchantApplyInfo(MerchantApplyInfo merchantApplyInfo)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        merchantApplyInfo.setOperatorId(String.valueOf(loginUser.getUserId()));
        merchantApplyInfo.setOperatorName(String.valueOf(loginUser.getUsername()));

        merchantApplyInfo.setUpdateTime(DateUtils.getNowDate());
        int i = merchantApplyInfoMapper.updateMerchantApplyInfo(merchantApplyInfo);

        return i;
    }

    /**
     * 批量删除商户申请信息
     * 
     * @param ids 需要删除的商户申请信息主键
     * @return 结果
     */
    @Override
    public int deleteMerchantApplyInfoByIds(Long[] ids)
    {
        return merchantApplyInfoMapper.deleteMerchantApplyInfoByIds(ids);
    }

    /**
     * 删除商户申请信息信息
     * 
     * @param id 商户申请信息主键
     * @return 结果
     */
    @Override
    public int deleteMerchantApplyInfoById(Long id)
    {
        return merchantApplyInfoMapper.deleteMerchantApplyInfoById(id);
    }
}
